package com.concurrent.concurrentdemo.lock.zkLock;

import com.concurrent.concurrentdemo.lock.QueueLock;
import org.I0Itec.zkclient.ZkLock;

import java.util.concurrent.CountDownLatch;

public class ZkLockTest {

    public static int num = 0;

    public static void main(String[] args) throws InterruptedException {
        ZkLock lock = new ZkLock();
        CountDownLatch countDownLatch = new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                lock.lock();
                for (int j = 0; j < 100000; j++) {
                    num++;
                }
                countDownLatch.countDown();
                lock.unlock();
            }).start();
        }
        countDownLatch.await();
        System.out.println(num);
    }
}
